<#assign path=request.contextPath>
<#assign basePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/">
<!DOCTYPE html>
<html>
<head>
    <title>WebDesign Admin - Checkhomework</title>

    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>

    <!-- bootstrap -->
    <link href="${path}/css/bootstrap/bootstrap.css" rel="stylesheet"/>
    <link href="${path}/css/bootstrap/bootstrap-responsive.css" rel="stylesheet"/>
    <link href="${path}/css/bootstrap/bootstrap-overrides.css" type="text/css" rel="stylesheet"/>

    <!-- global styles -->
    <link rel="stylesheet" type="text/css" href="${path}/css/layout.css"/>
    <link rel="stylesheet" type="text/css" href="${path}/css/elements.css"/>
    <link rel="stylesheet" type="text/css" href="${path}/css/icons.css"/>

    <!-- libraries -->
    <link href="${path}/css/lib/font-awesome.css" type="text/css" rel="stylesheet"/>

    <!-- this page specific styles -->
    <link rel="stylesheet" href="${path}/css/compiled/tables.css" type="text/css" media="screen"/>
    <link rel="stylesheet" href="${path}/css/compiled/index.css" type="text/css" media="screen"/>

    <!-- open sans font -->
    <link href='http://fonts.useso.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800'
          rel='stylesheet' type='text/css'/>

    <!--[if lt IE 9]>
    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body>

<!-- navbar -->
    <div class="navbar navbar-inverse">
        <div class="navbar-inner">
            <a class="brand" href="index.html"><img src="${path}/img/logo-login.png" /></a>

            			<ul class="nav pull-right">
				<!--无序列表-->
				 <li>
                	<a href="${path}/teacher/selectTerm?terminfo=${termid}">
                   	${username}
                	</a>
            	</li>
				<div class="copyrights"></div>

				<li class="hidden-phone">
                    <a href="${path}/teacher/showRewrite">修改密码</a>
                </li>

                <li class="hidden-phone">
                    <a href="${path}/common/logout">注销</a>
                </li>
			</ul>
		</div>
	</div>
    <!-- end navbar -->

     <!-- sidebar -->
	<div id="sidebar-nav">
		<ul id="dashboard-menu">
              <li class="adm">     
              <font size=3><b>
              <!--<span>当前学年为：</span>-->
              <#if termname?exists>
              	${termname}
              </#if>
              </b></font>
		    </li>
			<li>
				<a href="${path}/teacher/showTermAndHomework"> <i class="icon-home"></i>
					<span>教师主页</span>
				</a>
			</li>

			<li><a href="${path}/teacher/assignHomework"> <i
					class="icon-edit"></i> <span>作业发布</span>
			</a></li>

			<li  class="active">
			<div class="pointer">
					<div class="arrow"></div>
					<div class="arrow_border"></div>
				</div> 
			<a href="${path}/teacher/TermSum">
			 <i class="icon-signal"></i> <span>作业查看</span>
			</a></li>

			<li><a href="${path}/common/homeworkDisplay"> <i class="icon-picture"></i>
					<span>作业展示</span>
			</a></li>

			<li>
				<a class="dropdown-toggle" href="#"> 
					<i class="icon-group"></i> <span>学生/学年管理</span> 
					<i class="icon-chevron-down"></i>
				</a>
				<ul class="submenu">
					<li><a href="${path}/teacher/terms">新建学年</a></li>
					<li><a href="${path}/teacher/showUsers">密码重置</a></li>
				</ul>
			</li>
	</div>
	<!-- end sidebar -->

<!-- main container -->
<div class="content">
    <div class="container-fluid">
        <div id="pad-wrapper">
            <!-- products table-->
            <!-- the script for the toggle all checkboxes from header is located in js/theme.js -->
            <div class="table-wrapper products-table table-products section"><!--table-wrapper在tables.css-->
                <div class="row-fluid filter-block">
                  
                </div>
                <div class="row-fluid">
                	<form action="${path}/teacher/redirectDisplay" id="display" method="post">
                    <table class="table table-hover">
                        <thead>
                        <tr>
                            <th class="span3">
                             	<span class="line"></span>学号
                            </th>
                            <th class="span3">
                                <span class="line"></span>姓名
                            </th>
                            <th class="span3">
                                <span class="line"></span>查看
                            </th>
                            <th class="span3">
                                <span class="line"></span>分数
                            </th>
                            <th>
                            	<span class="line"></span>加入展示列表？
                            </th>
                        </tr>
                        </thead>
                        <tbody>
                        <!-- row -->
                        <#list homeworklist as work>
                        <tr>
                            <td>${work.userid}</td>
                            <td>${work.username}</td>
                            <td>
                                <a href="${work.address}">
                                	<span class="label label-success">查看</span>
                                </a>
                            </td>
                            <td>
                            <#if work.graded==0>
                            	<input type="text" name="score" value=${work.score} readonly style="width:30px;margin-top: 11px;"/>
                           
                            <#else>
                            	<input type="text" name="score" value=${work.score} style="width:30px;margin-top: 11px;" />　
                            	<input type="hidden" name="userhomeworkid" value=${work.userhomeworkid} />
                            	<input type="button" class="btn-flat gray" id="pingfen" onclick="charge(this);" value="评分"/>
                           
                             </#if>
                            
                            </td>
                            <td>
                            	<input type="checkbox" name="userhomeworkids" value=${work.userhomeworkid} />
                            </td>
                       		
                        </tr>
                        </#list>
                        <tr>
                        	<td></td>
                        	<td></td>
                        	<td></td>
                        	<td></td>
                        	<td>
                        		<input type="button" class="btn-flat gray" onclick="sub();" value="提交"/>
                      		</td>
                        </tr>
                        </tbody>
                    </table>
                   </form>
                </div>
            </div>
            <!-- end products table -->
        </div>
    </div>
</div>
<!-- end main container -->

<!-- scripts -->
<script src="${path}/js/jquery-latest.js"></script>
<script src="${path}/js/bootstrap.min.js"></script>
<script src="${path}/js/theme.js"></script>
<script type="text/javascript">

	function sub(){
		var homeworks = document.getElementsByName('userhomeworkids');
		var flag = 0;
		for(var i=0;i<homeworks.length;i++){
	         if(homeworks[i].checked){
	         flag = 1;
	         break;
	       }
	    } 
		if(flag == 0){
			alert("请选择要加入展示列表的作业");
		}else{
			$('#display').submit();
		}
		
	}
	
	function charge(obj){
		var btn = $(obj);
		var userhomeworkid = btn.prev();
		var score = userhomeworkid.prev();
		$.ajax({
			url : "${path}/ajax/grade",
			data: {userhomeworkid:userhomeworkid.val(), score:score.val() },
			type : "post",
			dataType : "json",
			error : function() {
				$('#SecondList').append('请求出错！');
			},
			success : function(responseResult) {
				if(responseResult.flag == true){
					alert("提交成功");
				}else{
					alert("提交失败");
				}
			}
		});
	}         
		
</script>
	
</body>
</html>